//
//  main.m
//  4.7Practice
//
//  Created by mac on 4/7/16.
//  Copyright (c) 2016 liuchengming. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Atom.h"
#import "Animal.h"
#import "Preson.h"
#import "Mouse.h"
int main(int argc, const char * argv[])
{

    @autoreleasepool
    {
        NSLog(@"Hello, World!");
        Atom *atom =[[Atom alloc]init];
        NSLog(@"Atom chemical element name:%@",atom.chemicalElement);
        
        Animal *ani=[[Animal alloc]init];
        ani.name= @"动物类";
        
        Preson *p =[[Preson alloc]init];
        p.name = @"张三";
        
        Mouse * mouse =[[Mouse alloc]init];
        mouse.name=@"老鼠";
        
        NSArray *arr =@[p,mouse];
        for (int i=0; i<arr.count; i++)
        {
            Animal *ani =arr[i];
            [ani eat];
            [ani sleep];
        }
        
        [mouse makeRole];
        [p say];
        
        
        NSArray * arra = @[ani,p,mouse];
        NSLog(@"names: %@",[arra componentsJoinedByString:@","]);
        
        NSString *str =@"hello,world,how,are,you";
        NSArray *ano=[str componentsSeparatedByString:@","];
        for (int i=0; i<ano.count; i++)
        {
            NSLog(@"%d.%@",i+1,ano[i]);
        }
        
        NSString * str1=@"a,d,c,e,b";
        NSArray *ano1 =[str1 componentsSeparatedByString:@","];
        ano1=[ano1 sortedArrayUsingSelector :@selector(compare:)];
        for (int i=0; i<ano1.count ; i++)
        {
            NSNumber *s = ano1[i];
            NSLog(@"%d.%@", i, s);
        }
        
        
        NSArray *ano2 = @[@(1), @(3), @(4), @(2),@(9)];
        ano2 = [ano2 sortedArrayUsingSelector:@selector(compare:)];
        for (int i = 0; i < ano2.count; i++)
        {
            NSNumber *s = ano2[i];
            NSLog(@"%d.%@", i+1, s);
        }
        
    }
    return 0;
    
}

